package com.ming.mallchat.common.user.service.impl;

import com.ming.mallchat.common.user.cache.UserCache;
import com.ming.mallchat.common.user.domain.enums.RoleEnum;
import com.ming.mallchat.common.user.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * @author 86150
 * @description 针对表【role(角色表)】的数据库操作Service实现
 * @createDate 2023-10-09 16:29:42
 */
@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private UserCache cache;

    /**
     * 是否拥有某个权限 临时写法
     *
     * @param uid
     * @return boolean
     */
    @Override
    public boolean hasRole(Long uid) {
        Set<Long> roleSet = cache.getRoleSet(uid);
        return roleSet.contains(RoleEnum.ADMIN.getId());
    }

}




